Remove barbaric abuse of goto out of one nested block and into a previous one.
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Fri, 18 Nov 2005 13:28:38 +0000 (14:28 +0100)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Fri, 18 Nov 2005 13:28:38 +0000 (14:28 +0100)
Remove one other -- less barbaric but still horrible -- use of goto.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/lowlevel/xc/xc.c

index 3283ca74e5eb5990ba086123aaf47383e76bf406..139f0fb81f88b8923d0e1171ec3480874ff3ab0e 100644 (file)
@@ -49,19 +49,16 @@ static PyObject *pyxc_domain_dumpcore(PyObject *self,
 
     if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is", kwd_list,
                                       &dom, &corefile) )
-        goto exit;
+        return NULL;
 
     if ( (corefile == NULL) || (corefile[0] == '\0') )
-        goto exit;
+        return NULL;
 
     if ( xc_domain_dumpcore(xc->xc_handle, dom, corefile) != 0 )
         return PyErr_SetFromErrno(xc_error);
     
     Py_INCREF(zero);
     return zero;
-
- exit:
-    return NULL;
 }
 
 static PyObject *pyxc_handle(PyObject *self)
@@ -95,12 +92,7 @@ static PyObject *pyxc_domain_create(PyObject *self,
     {
         if ( !PyList_Check(pyhandle) || 
              (PyList_Size(pyhandle) != sizeof(xen_domain_handle_t)) )
-        {
-        out_exception:
-            errno = EINVAL;
-            PyErr_SetFromErrno(xc_error);
-            return NULL;
-        }
+            goto out_exception;
 
         for ( i = 0; i < sizeof(xen_domain_handle_t); i++ )
         {
@@ -115,6 +107,11 @@ static PyObject *pyxc_domain_create(PyObject *self,
         return PyErr_SetFromErrno(xc_error);
 
     return PyInt_FromLong(dom);
+
+out_exception:
+    errno = EINVAL;
+    PyErr_SetFromErrno(xc_error);
+    return NULL;
 }
 
 static PyObject *pyxc_domain_max_vcpus(PyObject *self,
@@ -270,10 +267,7 @@ static PyObject *pyxc_domain_sethandle(PyObject *self,
     if ( !PyList_Check(pyhandle) || 
          (PyList_Size(pyhandle) != sizeof(xen_domain_handle_t)) )
     {
-    out_exception:
-        errno = EINVAL;
-        PyErr_SetFromErrno(xc_error);
-        return NULL;
+        goto out_exception;
     }
 
     for ( i = 0; i < sizeof(xen_domain_handle_t); i++ )
@@ -289,8 +283,14 @@ static PyObject *pyxc_domain_sethandle(PyObject *self,
     
     Py_INCREF(zero);
     return zero;
+
+out_exception:
+    errno = EINVAL;
+    PyErr_SetFromErrno(xc_error);
+    return NULL;
 }
 
+
 static PyObject *pyxc_domain_getinfo(PyObject *self,
                                      PyObject *args,
                                      PyObject *kwds)